package com.augn.controller;

import com.augn.entity.CulturalHeritage;
import com.augn.entity.CulturalHeritage;
import com.augn.entity.Result;
import com.augn.service.ICulturalHeritageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Iterator;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author augn
 * @since 2022-09-22
 */
@RestController
@RequestMapping("/culturalHeritage")
public class CulturalHeritageController {

    @Autowired
    private ICulturalHeritageService service;

    @PostMapping("/insertOne")
    public Result<?> insertOneCulturalHeritage(@RequestBody CulturalHeritage culturalHeritage) {
        return service.insertOneCulturalHeritage(culturalHeritage);
    }

    @DeleteMapping("/deleteOne/{id}")
    public Result<?> deleteOneCulturalHeritage(@PathVariable Integer id) {
        return service.deleteOneCulturalHeritage(id);
    }

    @PutMapping("/updateOne")
    public Result<?> updateOneCulturalHeritage(@RequestBody CulturalHeritage culturalHeritage) {
        return service.updateOneCulturalHeritage(culturalHeritage);
    }

    @GetMapping("/getOne/{id}")
    public Result<?> getOneCulturalHeritage(@PathVariable Integer id) {
        return service.getOneCulturalHeritage(id);
    }

    @PostMapping("/getPart")
    public Result<?> getPartCulturalHeritage(@RequestBody CulturalHeritage culturalHeritage,
                                  @RequestParam(required = false) Integer pageNum,
                                  @RequestParam(required = false) Integer pageSize) {
        return service.getPartCulturalHeritage(culturalHeritage,pageNum,pageSize);
    }

}
